<template>
  <el-button
    :style="{ minWidth: type == 'text' ? 'auto' : width }"
    :loading="loading"
    :disabled="disabled"
    :size="size"
    :type="type"
    :icon="icon"
    @click="handleClick"
  >
    <slot>{{ text }}</slot>
  </el-button>
</template>

<script>
export default {
  name: 'MButton',
  props: {
    type: {
      type: String,
      default: 'primary',
    },
    size: {
      type: String,
    },
    width: {
      type: String,
      default: '70px',
    },
    icon: {
      type: String,
      default: '',
    },
    text: {
      type: String,
      default: '',
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    loading: {
      type: Boolean,
      default: false,
    },
  },
  methods: {
    handleClick() {
      this.$emit('click')
    },
  },
}
</script>
